[FEATURE] Add a Auto Setup files for Windows ,Linux ,Mac os for Devloper to easily setup in one click #445 - #446
Conversation
|
@HindzStark is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdded Windows, Linux, and macOS setup scripts. The scripts validate environment files, install dependencies, generate Prisma Client, optionally run migrations, and print startup instructions. Added npm commands and setup documentation. ChangesCross-platform developer setup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant SetupScript
participant EnvironmentFiles
participant pnpm
participant Prisma
Developer->>SetupScript: Run platform-specific setup command
SetupScript->>EnvironmentFiles: Validate or create environment files
SetupScript->>pnpm: Install workspace dependencies
SetupScript->>Prisma: Generate Prisma Client
SetupScript->>Prisma: Optionally run development migrations
SetupScript-->>Developer: Print startup command and local URLs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Warning |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@setup/README.md`:
- Around line 44-48: Update the “Smart Re-run (Idempotency)” statement to
accurately describe the validation performed by the setup scripts: they only
verify that required environment variables are non-empty, not that values such
as DATABASE_URL are valid. Keep the existing skip-prompts behavior documented
without claiming format validation.
In `@setup/setup-linux.sh`:
- Around line 60-77: Require valid environment values before initialization: in
setup/setup-linux.sh lines 60-77, setup/setup-mac.sh lines 60-77, and
setup/setup-windows.ps1 lines 52-69, prompt for missing API values, revalidate
after any file creation or user response, and exit if required values remain
invalid. In setup/setup-linux.sh lines 87-109, setup/setup-mac.sh lines 87-109,
and setup/setup-windows.ps1 lines 80-102, validate NEXT_PUBLIC_API_URL and
NEXTAUTH_SECRET in existing environment files before reporting success or
continuing with dependency and Prisma initialization; preserve the existing
API_ENV_PATH/API_NEEDS_ATTENTION flow.
In `@setup/setup-windows.ps1`:
- Around line 111-116: Update setup-windows.ps1 so the pnpm-driven setup flow
stops immediately on native command failures: after each pnpm invocation in the
root dependency install/update path and the later Prisma generation/migration
steps, check $LASTEXITCODE and throw if it is nonzero. Keep the existing control
flow in the setup script, but ensure the symbols around the pnpm calls and the
success banner cannot proceed after a failed install, generate, or migrate.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 72bf52bd-b5f1-470e-93a8-1870425dd93a
📒 Files selected for processing (5)
package.jsonsetup/README.mdsetup/setup-linux.shsetup/setup-mac.shsetup/setup-windows.ps1
| 1. **Environment Variables Check (`.env` & `.env.local`)**: | ||
| - Verifies that `apps/api/.env` and `apps/web/.env.local` are present. | ||
| - Checks that essential variables (e.g., `DATABASE_URL`, `JWT_SECRET`, `PORT`, `NEXT_PUBLIC_API_URL`) are populated. | ||
| - If missing, guides you on what values are required to run locally. | ||
| - **Smart Re-run (Idempotency):** If `.env` files are already configured, it skips prompts on subsequent runs. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Align the rerun claim with the actual validation.
setup/setup-linux.sh:28-39 accepts any non-empty value for a required key. A value such as DATABASE_URL=placeholder can therefore pass the check and skip the prompts described here.
Either validate value formats before declaring the files configured, or change line 48 to state that the scripts check for non-empty values only.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/README.md` around lines 44 - 48, Update the “Smart Re-run
(Idempotency)” statement to accurately describe the validation performed by the
setup scripts: they only verify that required environment variables are
non-empty, not that values such as DATABASE_URL are valid. Keep the existing
skip-prompts behavior documented without claiming format validation.
| if [ "$API_NEEDS_ATTENTION" = true ]; then | ||
| echo "" | ||
| echo -e "${CYAN}📌 Important environment variables for apps/api/.env:${NC}" | ||
| echo -e "${GRAY} - DATABASE_URL (e.g., postgresql://postgres:postgres@localhost:5432/opensox?schema=public)${NC}" | ||
| echo -e "${GRAY} - JWT_SECRET (e.g., a-random-secret-key)${NC}" | ||
| echo -e "${GRAY} - PORT (default: 8080)${NC}" | ||
| echo "" | ||
|
|
||
| if [ ! -f "$API_ENV_PATH" ]; then | ||
| read -p "Would you like to copy apps/api/.env.example to apps/api/.env now? (Y/n) " -n 1 -r | ||
| echo "" | ||
| if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then | ||
| cp "$API_ENV_EXAMPLE" "$API_ENV_PATH" | ||
| echo -e "${GREEN}✅ Created apps/api/.env from .env.example. Please review and update DATABASE_URL if needed.${NC}" | ||
| else | ||
| echo -e "${YELLOW}Please create apps/api/.env manually with essential keys before running the app.${NC}" | ||
| fi | ||
| fi |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Require valid environment values before initialization.
The scripts only show warnings when required values are absent. A user can decline file creation, or keep incomplete files, and setup still runs dependency and Prisma commands. This does not meet the required prompt-and-confirm setup flow.
setup/setup-linux.sh#L60-L77: Prompt for missing API values, revalidate them, and exit before initialization when they remain invalid.setup/setup-linux.sh#L87-L109: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRETin existing files before reporting success or continuing.setup/setup-mac.sh#L60-L77: Prompt for missing API values, revalidate them, and exit before initialization when they remain invalid.setup/setup-mac.sh#L87-L109: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRETin existing files before reporting success or continuing.setup/setup-windows.ps1#L52-L69: Prompt for missing API values, revalidate them, and exit before initialization when they remain invalid.setup/setup-windows.ps1#L80-L102: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRETin existing files before reporting success or continuing.
📍 Affects 3 files
setup/setup-linux.sh#L60-L77(this comment)setup/setup-linux.sh#L87-L109setup/setup-mac.sh#L60-L77setup/setup-mac.sh#L87-L109setup/setup-windows.ps1#L52-L69setup/setup-windows.ps1#L80-L102
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/setup-linux.sh` around lines 60 - 77, Require valid environment values
before initialization: in setup/setup-linux.sh lines 60-77, setup/setup-mac.sh
lines 60-77, and setup/setup-windows.ps1 lines 52-69, prompt for missing API
values, revalidate after any file creation or user response, and exit if
required values remain invalid. In setup/setup-linux.sh lines 87-109,
setup/setup-mac.sh lines 87-109, and setup/setup-windows.ps1 lines 80-102,
validate NEXT_PUBLIC_API_URL and NEXTAUTH_SECRET in existing environment files
before reporting success or continuing with dependency and Prisma
initialization; preserve the existing API_ENV_PATH/API_NEEDS_ATTENTION flow.
| if (-not (Test-Path (Join-Path $RootDir "node_modules"))) { | ||
| Write-Host "Installing dependencies with pnpm..." -ForegroundColor Cyan | ||
| pnpm install | ||
| } else { | ||
| Write-Host "[OK] Root node_modules found. Checking for updates..." -ForegroundColor Green | ||
| pnpm install --prefer-offline |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Stop the script when a pnpm command fails.
PowerShell does not throw by default when a native command returns a nonzero exit code. A failed pnpm install, Prisma generation, or migration can therefore continue to the success banner. Check $LASTEXITCODE after each pnpm call and throw when it is nonzero.
Proposed fix
+function Invoke-Pnpm {
+ param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
+
+ & pnpm `@Arguments`
+ if ($LASTEXITCODE -ne 0) {
+ throw "pnpm $($Arguments -join ' ') failed with exit code $LASTEXITCODE."
+ }
+}
+
- pnpm install
+ Invoke-Pnpm install
...
-pnpm --filter api exec prisma generate
+Invoke-Pnpm --filter api exec prisma generate
...
- pnpm --filter api exec prisma migrate dev
+ Invoke-Pnpm --filter api exec prisma migrate devAlso applies to: 127-133
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/setup-windows.ps1` around lines 111 - 116, Update setup-windows.ps1 so
the pnpm-driven setup flow stops immediately on native command failures: after
each pnpm invocation in the root dependency install/update path and the later
Prisma generation/migration steps, check $LASTEXITCODE and throw if it is
nonzero. Keep the existing control flow in the setup script, but ensure the
symbols around the pnpm calls and the success banner cannot proceed after a
failed install, generate, or migrate.
Summary
This PR adds interactive setup scripts for Windows, Linux, and macOS to simplify the local development setup process.
Closes #445
Changes
setup-windows.ps1setup-linux.shsetup-mac.shpnpm install)pnpm exec prisma generate)README.mdwith streamlined setup instructions for all supported operating systemsBenefits
Summary by CodeRabbit
New Features
Documentation